home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / orbitsou.cpt / Orbit Source ƒ / orbdial.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-03-07  |  3.0 KB  |  119 lines

  1. /* Handle dialogs for Orbit.c */
  2. /* Copyright 1987                            */
  3. /* David Palmer                             */
  4. /* Mail code 220-47                            */
  5. /* California Institute Of Technology         */
  6. /* Uses EasyDialog.c  (also ⌐ 1987 By David Palmer) */
  7. /* Duplication, modification, and examination allowed on a    */
  8. /* non-commercial basis only.  Commercial use prohibited    */
  9. /* without prior written agreement with the author.  (This    */
  10. /* includes sale by for-profit companies, and use as an        */
  11. /* inducement to buy something.)                            */
  12.  
  13. #include <DialogMgr.h>
  14. #include <EasyDialog.h>
  15. #include "orbit.h"
  16.  
  17. #define PARAMETERS 256
  18. #define INITIAL 257
  19. #define BLAME 258
  20.  
  21. int whichbutton = 1;
  22. extern double precision;
  23. extern double scale;
  24. extern double drawperiod;
  25. extern int trailstyle;
  26. extern int fcenter;
  27. extern int background;
  28. int unitlength = 4;
  29. double lengthunits[] = {1, 1e-2, 1, 1e3, 150e9, 9.4e15};
  30. int unitimage = 2;
  31. double imageunits[] = {1, 1, 72, 512};
  32. int unittime = 2;
  33. double timeunits[] = {1, 1, 86400., 3.15e7};
  34. int unitmass = 4;
  35. double massunits[] = {1, 1e-3, 1, 6e24, 2e30};
  36. int unitspeed = 4;
  37. double speedunits[] = {1, 1e-2, 1, 1e3, 4775, 3e8};
  38.  
  39.  
  40. int funcblame();
  41.  
  42. PARTICLE pastat = {1, 0, 0, 0,
  43.                          0, 0, 0,
  44.                          0, 0, 0,
  45.                          0, 0, 0,
  46.                          {0, 0}};
  47.  
  48. EDITEM parlist[] = {
  49.         {2, 1, edbutton, &whichbutton, 0, NULL},
  50.         {1, 4, edfloat, &precision, 1, NULL},
  51.         {1, 6, edfloat, &scale, 1, NULL},
  52.         {1, 8, edfloat, &drawperiod, 1, NULL},
  53.         {5, 9, edrad, &unitlength, 1, NULL},
  54.         {3, 15, edrad, &unitimage, 1, NULL},
  55.         {3, 18, edrad, &unittime, 1, NULL},
  56.         {3, 22, edrad, &trailstyle, 1, NULL},
  57.         {1, 25, edcheck, &fcenter, 1, NULL},
  58.         {1, 26, edcheck, &background, 1, NULL},
  59.         {3, 27, edbutton, &whichbutton, 0, funcblame},
  60.         {0, 0, edlast, NULL, 0, NULL}};
  61.  
  62. EDITEM initlist[] = {
  63.         {3, 1, edbutton, &whichbutton, 0, NULL},
  64.         {7, 10, edfloat, &pastat, 1, NULL},
  65.         {4, 17, edrad, &unitmass, 1, NULL},
  66.         {5, 21, edrad, &unitlength, 1, NULL},
  67.         {5, 26, edrad, &unitspeed, 1, NULL},
  68.         {0, 0, edlast, NULL, 0, NULL}};
  69.  
  70. EDITEM blamelist[] = {
  71.         {1, 1, edbutton, &whichbutton, 0, NULL},
  72.         {0, 0, edlast, NULL, 0, NULL}};
  73.         
  74. GetParams()
  75. {
  76.     scale /= (lengthunits[unitlength]/imageunits[unitimage]);
  77.     drawperiod /= timeunits[unittime];    
  78.     if (1 == EasyDialog(PARAMETERS, parlist)) {
  79.         scale *= (lengthunits[unitlength]/imageunits[unitimage]);
  80.         drawperiod *= timeunits[unittime];
  81.         return;
  82.     } else
  83.         exit(0);
  84. }
  85.  
  86. GetInit(ppa)
  87. PARTICLE *ppa;
  88. {
  89.     int whichbutton, i;
  90.     
  91.     whichbutton = EasyDialog(INITIAL, initlist);
  92.     if (whichbutton != 3) {
  93.         *ppa = pastat;
  94.         ppa->m *= massunits[unitmass];
  95.         for (i = 0 ; i < NDIMS ; i++) {
  96.             ppa->f[i] = 0;
  97.             ppa->x[i] *= lengthunits[unitlength];
  98.             ppa->xt[i] = ppa->x[i];
  99.             ppa->p[i] *= ppa->m * speedunits[unitspeed];
  100.         }
  101.     }
  102.     return whichbutton;
  103. }
  104.  
  105. int funcblame(pdi, pedi, pedihit, itemnum)
  106. DialogPtr pdi;
  107. EDITEM *pedi, *pedihit;
  108. {
  109.     if (itemnum == 27) {
  110.         EasyDialog(BLAME, blamelist);
  111.         return 0;
  112.     } else if (itemnum == 28) {
  113.         /* load scenario */
  114.         return 0;
  115.     } else if (itemnum == 29) {
  116.         /* load scenario */
  117.         return 3;
  118.     }
  119. }